feat: add superstruct.sensitive#577
Open
ccharly wants to merge 5 commits into
Open
Conversation
ccharly
commented
Jun 25, 2026
ccharly
commented
Jun 25, 2026
ccharly
commented
Jun 25, 2026
| * The private key of the exported account. | ||
| */ | ||
| privateKey: string(), | ||
| privateKey: sensitive(string()), |
Contributor
Author
There was a problem hiding this comment.
Since it's marked as sensitive AND that we use our object struct, this field will never be display in validation/error messages from superstruct.
8cc422c to
fffcf37
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
hmalik88
reviewed
Jul 16, 2026
Contributor
|
Can we also add |
Co-authored-by: Hassan Malik <41640681+hmalik88@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding a new
superstruct"decorator" to mark a field as "sensitive" this way, it never gets logged by mistake insuperstructerror messages.Requires:
sensitivestruct superstruct#41Note
Medium Risk
Touches private-key export validation and error reporting; the change reduces leakage risk but depends on superstruct redaction behaving correctly everywhere errors are logged.
Overview
Adopts
@metamask/superstruct3.4.0 and its newsensitive()decorator across the keyring packages so marked fields are redacted inStructErroroutput.In keyring-api,
PrivateKeyExportedAccountStruct.privateKeyis changed fromstring()tosensitive(string()), so failed validation no longer leaks the raw key inerror.value,error.message, orfailure.branch. New unit tests inprivate-key.test.tslock in that behavior for invalidprivateKeyvalues and when a sibling field (e.g.encoding) fails.Reviewed by Cursor Bugbot for commit 69d4cd8. Bugbot is set up for automated code reviews on this repo. Configure here.